<?php /*a:1:{s:72:"D:\wamp64\www\tpadmin\application\admin\view\admin\permission\index.html";i:1568113688;}*/ ?>
<div>
  <div class="main-title">
    <h2>权限管理</h2>
  </div>
  <div class="main-section form-inline">
    <a href="<?php echo url('edit', ['admin_role_id' => $admin_role_id]); ?>" class="btn btn-success">+ 新增</a>
    <select class="j-select form-control" style="width:120px;margin-left:2px">
      <option value="<?php echo url('', ['admin_role_id' => 0]); ?>">未选择</option>
      <?php foreach($roles as $v): ?>
      <option value="<?php echo url('', ['admin_role_id' => $v['id']]); ?>" <?php if($admin_role_id==$v['id']): ?>selected<?php endif; ?>><?php echo htmlentities($v['name']); ?> </option>
      <?php endforeach; ?>
    </select>
  </div>
  <div class="main-section">
    <table class="table table-striped table-bordered table-hover">
      <thead>
        <tr>
          <th>角色</th>
          <th>允许的控制器</th>
          <th>允许的操作</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <?php if($role): foreach($role['adminPermission'] as $v): ?>
        <tr>
          <td>
            <a href="<?php echo url('admin.role/edit', ['id' => $role['id']]); ?>" class="j-menu-to"><?php echo htmlentities($role['name']); ?></a>
          </td>
          <td><?php echo htmlentities($v['controller']); ?></td>
          <td><?php echo htmlentities($v['action']); ?></td>
          <td>
            <a href="<?php echo url('edit', ['id' => $v['id']]); ?>" style="margin-right:5px;">编辑</a>
            <a href="<?php echo url('delete', ['id' => $v['id']]); ?>" class="j-del text-danger">删除</a>
          </td>
        </tr>
        <?php endforeach; ?>
        <?php endif; if(empty($role) || $role->adminPermission->isEmpty()): ?>
        <tr>
          <td colspan="4" class="text-center">列表为空</td>
        </tr>
        <?php endif; ?>
      </tbody>
    </table>
  </div>
</div>
<script>
  $('.j-del').click(function() {
    if (confirm('您确定要删除此项？')) {
      main.ajaxPost($(this).attr('href'), function() {
        main.contentRefresh();
      });
    }
    return false;
  });
  $('.j-menu-to').click(function() {
    main.content($(this).attr('href'), function() {
      main.menuActive('admin.role');
    });
    return false;
  });
  $('.j-select').change(function() {
    main.content($(this).val());
  });
</script>